package edu.maping.easy.gui;

import processing.core.PApplet;
import processing.core.PGraphics;
import fisica.FBox;

public class Button extends FBox {

	public String name = null;
	float textOffset = 0;
	float x, y = 0;
	private float noWorld = 1357;

	public Button(String name, float x, float y, int width, int height,
			PApplet pApplet) {
		super(width, height);
		this.name = name;
		textOffset = pApplet.textAscent() - pApplet.getHeight() / 2;
		setStatic(true);
		setPosition(x, y);
		setGrabbable(false);
	}

	public void draw(PGraphics applet) {
		super.draw(applet);
		preDraw(applet);
		applet.fill(255);
		applet.textAlign(PApplet.CENTER);
		applet.textSize(12);
		applet.text(name, 0, 5);
		postDraw(applet);
	}

	public int getColor() {
		return m_fillColor;
	}

	@Override
	public void setDrawable(boolean drawable) {
		super.setDrawable(drawable);
//		if (drawable == false) {
//			x = getX();
//			y = getY();
//			
//			super.setPosition(noWorld, noWorld);
//		} else {
//			setPosition(x, y);
//		}
	}

	@Override
	public void setPosition(float x, float y) {
//		this.x = x;
//		this.y = y;
//
//		if (isDrawable())
			super.setPosition(x, y);
	}
}
